<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改系统 - 任务主体')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-task-edit" th:object="${cstTask}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">任务名称：</label>
            <div class="col-sm-8">
                <input name="title" th:field="*{title}" class="form-control" type="text">
            </div>
        </div>
       <!-- <div class="form-group">
            <label class="col-sm-3 control-label">图片：</label>
            <div class="col-sm-8">
                <textarea name="img" class="form-control">[[*{img}]]</textarea>
            </div>
        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">内容：</label>
            <div class="col-sm-8">
                <input name="content" th:field="*{content}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">完成时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="finishTime" th:value="${#dates.format(cstTask.finishTime, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">内容：</label>
            <div class="col-sm-8">
                <input name="deptName" id="deptName" type="text" onclick="appointees()" class="form-control">
            </div>
        </div>
        <input type = "hidden" name="dId" id="dId"  >
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script type="text/javascript">
    var prefix = ctx + "system/task";

    function uploadFile() {
        var form = $("#form-task-edit")[0];
        var formData = new FormData(form);
        /*formData.append('file', files[0]);*/

        formData.append('dId',$('#dId')[0]);
        $.ajax({
            url: prefix + "/taskDo",
            type: 'post',
            cache: false,
            data: formData,
            processData: false,
            contentType: false,
            dataType: "json",
            success: function(result) {
                console.log(result)
                setTimeout(function(){
                    $.modal.close();
                },300);
                var parent = window.parent;
                parent.$.modal.msgSuccess("操作成功!");
                parent.$.table.refresh();
            }
        });
    }

    $("#form-task-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            uploadFile();
        }
    }

    $("input[name='finishTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='addtime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='publishTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='checkTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    function appointees() {
        var url=prefix+"/appointees";
        $.modal.open("查看通知公告",url,'900','600');//900页面宽度  600页面高度
        //$.modal.open弹出框打开
    }
</script>
</body>
</html>